import Ember from 'ember';
import InfiniteScroll from '../../infinite-scroll';

export default Ember.Controller.extend(InfiniteScroll,{
  dateService: Ember.inject.service("date-service"),
  pathConfiger: Ember.inject.service("path-configer"),
  service_PageConstrut:Ember.inject.service("page-constructure"),
  statusService: Ember.inject.service("current-status"),
  dataLoader: Ember.inject.service("data-loader"),
  feedService: Ember.inject.service('feed-bus'),

  infiniteContentPropertyName: "sleepmessageList",
  infiniteModelName: "sleepmessage",
  infiniteContainerName:"sleepCustomerInformationContainer",

  customerObs: function(){
    var _self = this;
    //获取headerbar中的老人id
    var customerId = this.get("healtyCustomerId");
    if(!customerId){
      //如果不存在id
      this.set("nocustomerId",true);
      _self.hideAllLoading();
      return;
    }else{
      //如果存在id,则是页面可以滑动
      this.set("stopScroll",false);
    }
    this.set("nocustomerId",false);
    this.set("customerId",customerId);
    var params = {
      filter:{
        customer:{id:customerId}
      },
      sort:{
        createDate:"desc"
      }
    };
    console.log("infiniteQuery run");
    this.infiniteQuery('sleepmessage',params);
  }.observes("healtyCustomerId").on("init"),

  actions:{
    switchShowAction(){
      this.directInitScoll();
    },
  },
});
